import { constantRoutes, asyncRoutes } from '@/router'
const state = {
    routes: []
}
const mutations = {
    setRoutes(state, data) {
        state.routes = [
            ...constantRoutes,
            ...data
        ]
    }
}
const actions = {
    filterRoutes(store, menus) {
        // const newAsyncRoutes = asyncRoutes.filter(item => menus.includes(item.name))
        const newAsyncRoutes = asyncRoutes.filter(item => menus.includes(item.name))
        // console.log('vuex 筛选路由', newAsyncRoutes)
        store.commit('setRoutes', newAsyncRoutes)
        return newAsyncRoutes
    }
}

export default {
    namespaced: true,
    state,
    mutations,
    actions
}